package com.kiwilss.aopdemo.ui.dsl

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.View
import androidx.annotation.ContentView
import com.kiwilss.aopdemo.R
import kotlinx.android.synthetic.main.pw_center.*

/**
 * @author : Administrator
 * e-mail : kiwilss@163.com
 * time   : 2021/02/05
 *  desc   :
 */

fun Context.dslPw(function: DslPw.() -> Unit): DslPw {
    val dslPw = DslPw(this)
    dslPw.also(function).show()
    return dslPw
}


class DslPw(context: Context) : Dialog(context) {

    var mTitle: String? = null
    var mLeftDec: String? = null
    var mRightDec: String? = null

    var mCancelClick: ((view: View) -> Unit)? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.pw_center)

        mTitle?.run {
            tv_pw_onetitle_title.text = mTitle
        }
        mLeftDec?.run {
            tv_pw_onetitle_cancel.text = mLeftDec
        }
        mRightDec?.run {
            tv_pw_onetitle_sure.text = mRightDec
        }

        mCancelClick?.run {
            tv_pw_onetitle_cancel.setOnClickListener(this)
        }
        mCancelClick?.run {
            tv_pw_onetitle_cancel.setOnClickListener(this)
        }


    }

    fun leftClick(click: ((view: View) -> Unit)?){
        mCancelClick = click
    }


}